﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DynamicObject_t
{
    public partial class ClassSelect : Form
    {
        List<EntityLayer.IClassEntity> _entyties;
        public ClassSelect(List<EntityLayer.IClassEntity> entyties)
        {
            InitializeComponent();
            _entyties = entyties; 
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void ClassSelect_Load(object sender, EventArgs e)
        {
            var Enti = _entyties;
            comboBox1.DataSource = Enti;
            comboBox1.DisplayMember = "Name";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var objejct = (from i in _entyties where i.Name == comboBox1.Text select i).FirstOrDefault();
            if (objejct != null)
            {               
                objejct.Add().ShowDialog();
                this.Close();
            }
        }
    }
}
